package java67_7;

import java.util.Arrays;

public class ArraySort {

	public static void main(String[] args) {
		int[] money = { 8, 4, 2, 1, 23, 34, 21 };
		// 冒泡
		// 和隔壁比较,不满足要求,调换位置
		int temp;
		for (int i = 0; i < money.length - 1; i++) {
			for (int j = 0; j < money.length - 1 - i; j++) {
				// j和j+1做比较,j大,则调换
				if (money[j] > money[j + 1]) {
					temp = money[j];
					money[j] = money[j + 1];
					money[j + 1] = temp;
				}
			}
		}
		// Arrays.sort(money);// 升序排序
		for (int i = 0; i < money.length; i++) {
			System.out.println("倒数第 " + (i + 1) + ",是:" + money[i]);
		}
	}

}
